<?php

use yii\db\Migration;

class m210222_082747_addon_archives extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%addon_archives}}', [
            'id' => "int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID'",
            'merchant_id' => "int(11) NULL DEFAULT '0'",
            'cate_id' => "int(11) NOT NULL COMMENT '分类'",
            'serial' => "varchar(32) NOT NULL COMMENT '编号'",
            'title' => "varchar(255) NOT NULL COMMENT '标题'",
            'cabinet' => "varchar(32) NOT NULL COMMENT '文件柜编号'",
            'box' => "varchar(32) NOT NULL COMMENT '文件盒编号'",
            'send_time' => "varchar(11) NOT NULL COMMENT '发文时间'",
            'covers' => "text NULL",
            'status' => "int(11) NOT NULL DEFAULT '1' COMMENT '状态'",
            'created_at' => "int(11) NOT NULL COMMENT '创建时间'",
            'updated_at' => "int(11) NOT NULL COMMENT '更新时间'",
            'PRIMARY KEY (`id`)'
        ], "ENGINE=InnoDB DEFAULT CHARSET=utf8");
        
        /* 索引设置 */
        
        
        /* 表数据 */
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%addon_archives}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

